{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "def f_outer(fn):\n",
    "    \n",
    "    def f_inner(x,y):\n",
    "        z = x ** 2 + y ** 2\n",
    "        print('这是吃过糖的结果')\n",
    "        return z\n",
    "    \n",
    "    return f_inner"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是吃过糖的结果\n",
      "这是吃过糖的结果\n",
      "这是吃过糖的结果\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(12, 17, 86)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def f_outer(fn):\n",
    "    def f_inner(x,y,z):\n",
    "        w = fn(x,y) + z\n",
    "        print('这是吃过糖的结果')\n",
    "        return w\n",
    "    \n",
    "    return f_inner\n",
    "\n",
    "@f_outer\n",
    "def f1(x,y):  #小秦才上一年级，只要算加法\n",
    "    z = x + y\n",
    "    return z\n",
    "\n",
    "@f_outer\n",
    "def f2(x,y):  #小赵上二年级，要算乘法\n",
    "    z = x * y\n",
    "    return z\n",
    "\n",
    "@f_outer\n",
    "def f3(x,y):  #小周上六年级了，要算幂次\n",
    "    z = x ** y\n",
    "    return z\n",
    "\n",
    "f1(3,4,5),f2(3,4,5),f3(3,4,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
